#include <stdio.h>
#include "wled.h"

/**
 * start by 
 *          ./ledgui -qws -display Transformed:Rot270
 */

int main(int argc, char *argv[])
 {
	system("cp wled_splash.16 /dev/fb0");
	 
	QApplication app(argc, argv);
	
	int maxurb = 0; // whole program will terminates after receiving 'maxurb' urbs. '0' == infinity
	if(argc==2)
		sscanf(argv[1], "%d", &maxurb);
	printf("maxurb = %d.\n", maxurb);
	
	WLed *w = new WLed;
	w->show();
	/* hide mouse cursor for all widget. do not use w.setCursor( QCursor( Qt::BlankCursor ) ); */
	app.setOverrideCursor( QCursor( Qt::BlankCursor ) );

	ReadURB *r = new ReadURB(w, maxurb);
	r->start();

#if 0
	/* GUI test code */
	w->setstate(w->RED, w->ON);
	w->setstate(w->GREEN, w->FLASH);
	w->setstate(w->BLUE, w->OFF);
	w->setlightness(w->GREEN, 200);
	w->setontime(w->GREEN, 200);
	w->showurb(1, 2, 3, 4, 5, "12345678");
	w->showurb(1, 2, 3, 4, 0, "12345678");
	w->showurb(1, 2, 3, 4, 0, "12345678");
	w->showurb(1, 2, 3, 4, 0, "12345678");
	w->showurb(1, 2, 3, 4, 0, "12345678");
	w->loudspeaker(123,234);
#endif

	int retValue = app.exec();
	printf("app.exec() finishes.\n");
	r->wait();
	printf("sub-thread finishes.\n");
	return retValue;
 }
